#ifndef SRC_CUBE_SIGNATURE
#define SRC_CUBE_SIGNATURE

#include "log_helper.hpp"
#include <vector>

class cube_signature {
public:
  cube_signature() = default; // a nullptr signature

  cube_signature(const cube_signature &other) { dims_ = other.dims_; }

  cube_signature(cube_signature &&other) { dims_ = std::move(other.dims_); }

  cube_signature(const long _dims[], long _ndims) { init(_dims, _ndims); }

  cube_signature(const std::vector<long> &_dims) { init(_dims); }

  void init(const long _dims[], long _ndims) {
    ASSERT_PRINTF(dims_.size() == 0,
                  "Can only initialize an un-initialized signature\n");
    for (auto i = 0; i < _ndims; i++) {
      dims_.push_back(_dims[i]);
    }
  }

  void init(const std::vector<long> &_dims) {
    init(_dims.data(), _dims.size());
  }

  bool empty() const { return dims_.empty(); }

  bool is_linear() const { return dims_.size() == 1; }

  bool is_2d() const { return dims_.size() == 2; }

  std::size_t ndims() const { return dims_.size(); }

  long size(std::size_t i) const { return dims_[i]; }

  const std::vector<long> &dims() const { return dims_; }

private:
  std::vector<long> dims_;
};

#endif /* SRC_CUBE_SIGNATURE */
